package com.vhall.component.aspect;

import com.vhall.component.framework.common.exception.BusinessException;
import com.vhall.component.plugin.common.aspect.BaseDataAspect;
import com.vhall.component.plugin.common.exception.BizErrorCode;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * UrlDisableAspect-
 *
 * @author xing.wang
 * @date 2024/2/28
 */
@Slf4j
@Aspect
@Component
@Order(1)
public class UrlDisableAspect extends BaseDataAspect  {
    @Pointcut("@annotation(com.vhall.component.plugin.common.annotation.UrlDisable) || @within(com.vhall.component.plugin.common.annotation.UrlDisable)")
    public void pointCut() {
        // Do nothing
    }
    @Around("pointCut()")
    public Object tokenBefore(ProceedingJoinPoint joinPoint) throws Throwable {
        log.error("你访问的接口已经被禁用");
        BusinessException businessException = new BusinessException(BizErrorCode.BIZ_NO_PERMISSION);
        businessException.setMsg("你访问的接口已经被禁用");
        throw businessException;
    }

}
